<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	
  </head>
  
  <body>
    <div class="easyui-layout" fit="true" >
		<div id="easyui_toolbar" region="north" border="true" style="border-bottom:1px solid #999;height:32px;">
		
			<div style="height:5px; width:100%;"></div>
			<div style="height:10px;width:620px;float:left;"></div>
		    <input class="easyui-searchbox" data-options="prompt:'请输入查询条件...',menu:'#mm',searcher:searchTask" style="width:300px"></input>
			<div id="mm">
				<div data-options="name:'task',iconCls:'icon-ok'">任务类型查找</div>
				<div data-options="name:'taskid'">任务编号查找</div>
				<div data-options="name:'taskstatus'">任务状态查找（隐藏、显示）</div>
			</div>
		</div>
		<%-- 表格数据区域 --%>
		<div region="center" border="false">
			<table id="taskTable" ></table>
		</div>
	</div>

	<img id="fullbutton" src="images/003.png" width="24" onClick="full()" style="position:absolute;right:50px; top:30px;"/>
	<script type="text/javascript">

	//查询商品的方法
	function searchTask(value,name){
		$("#taskTable").edatagrid({
			url:"backadmin/task.action?op=findTask",
		    saveUrl: "backadmin/task.action?op=addTask",
		    updateUrl: "backadmin/task.action?op=updateTask",
		    idField:"tid",
			pagination:true,
			pageNumber:1,
			pageSize:10,
			pageList:[10,20,30,40,50],
			fit:true,
			rownumbers:true,
			sortName:"tid",
			title:"任务类型列表",
			sortOrder:"desc",
			singleSelect:true,
			queryParams:{
				ttname:value,
				searchType:name
			},
			columns:[[
				{field:"tstatus",title:"任务状态",width:120,align:"center",editor:'text',
					formatter:function(value,rec){
						if(value==3){
							return "<a href='javascript:void(0)' style='color:red;' onClick='checktask(this,"+rec.tid+")'>点击通过审核</a>";
						}else if(value==1){
							return "<a href='javascript:void(0)' style='color:green; onClick='finishtask(this,"+rec.tid+")'>正在进行</a>";
						}else if(value==2){
							return "<a href='javascript:void(0)' style='color:reb(214,77,37);'>已完成</a>";
						}else if(value==4){
							return "<a href='javascript:void(0)' style='color:blue;'>冻结</a>";
						}else if(value==5){
							return "<a href='javascript:void(0)' style='color:#999;'>已过期</a>";
						}
					}},
				{field:"tid",title:"任务编号",width:100,align:"center"},
				{field:"uid",title:"发布者编号",width:100,align:"center"},
				{field:"taccid",title:"接受者编号",width:100,align:"center"},
				{field:"tsendtime",title:"发布时间",width:100,align:"center"},
				{field:"tstarttime",title:"任务开始时间",width:100,align:"center"},
				{field:"taddr",title:"任务地点",width:100,align:"center"},
				{field:"taim",title:"任务目标",width:100,align:"center"},
				{field:"ttid",title:"任务类型编号",width:100,align:"center"},
				{field:"tmore",title:"任务详情",width:100,align:"center"},
				{field:"tphoto",title:"任务图片",width:180,align:"center",
					formatter:function(value,rec){
	        			return '<img class="editCls1" src="images/mixedPicData/'+value+'" width="160" height="90" href="javascript:void(0)" />';
					}	
				},
				{field:"treward",title:"任务赏金",width:100,align:"center"},
				{field:"tbrowse",title:"任务浏览量",width:100,align:"center"},
				{field:"tider",title:"关注者列表",width:100,align:"center"},
				{field:"bbs",title:"操作",width:100,align:"center",
					formatter:function(value,rec){	
						return "<a href=\"javascript:void(0)\" style=\"color:blue\" onClick=\"caozuotask('frazetask',"+rec.tid+")\">冻结</a>/<a href=\"javascript:void(0)\" style=\"color:#999\" onClick=\"caozuotask('timeout',"+rec.tid+")\">过期</a>";
					}
				},
			]],
			toolbar:[
			         {
			        	 iconCls:'icon-save',
			        	 text:"保存",
			        	 handler:function(){
			        		 $("#taskTable").edatagrid('saveRow');//完成添加或更新
			        	 }
			         },{
			        	 iconCls:'icon-undo',
			        	 text:"取消编辑",
			        	 handler:function(){
			        		 $("#taskTable").edatagrid('cancelRow');
			        	 }
			  		  }
			  ]
		});
	}
	
	function finishtask(obj,tid){
		$.ajax({
			url:"backadmin/task.action?op=finishtask",
			type:"POST",
			dataType:"JSON",
			data:{"tid":tid},
			success:function(data){
				showinfobox(1,"",data.msg);
			}
		});
	}
	
	function caozuotask (type,tid){
		//alert(type+tid);
		$.ajax({
			url:"backadmin/task.action?op=caozuotask",
			type:"POST",
			dataType:"JSON",
			data:{"type":type,"tid":tid},
			success:function(data){
				showinfobox(1,"",data.msg);
			}
		});
	}
	
	function checktask(obj,uid){
		//alert(uid);
		$.ajax({
			url:"backadmin/task.action?op=checkTask",
			type:"POST",
			data:{"uid":uid},
			success:function(data){
				showinfobox(1,"","任务"+uid+"已通过审核...");
				$(obj).html("已通过审核");
				$(obj).css("color","green");
			}
		});
		
	}
	
	$(function(){
		searchTask(null,null);
	});
</script>	     

  </body>
</html>
